﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Baimasoft.Manage.SqlServerDAL;

public partial class SysManage_OutPage_Edit : System.Web.UI.Page
{
    UserManage MyUM = new UserManage();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {

            OutWebPageDropBind();
        }
    }


    public void OutWebPageDropBind()
    {
        OutPageID.DataSource = MyUM.GetOutPageInfo();
        OutPageID.DataBind();
        OutPageID.Items.Insert(0, "顶级组织");
        OutPageID.Items[0].Value = "0";
    }

    /// <summary>
    /// 保存信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void GrantBtn1_ServerClick(object sender, EventArgs e)
    {
        string sHPageID = HPageID.Value.ToString().Trim();
        string sHOldPageID = HOldPageID.Value.ToString().Trim();

        string sOutPageID = OutPageID.SelectedValue.ToString().Trim();
        string sOldOutPageID = HOldParentID.Value.ToString().Trim();

        string sLabel = Label.Text.ToString().Trim();
        string sIFLink = "1";

        if (IFLink.Checked == false)
        {
            sIFLink = "0";
        }

        string sLink = Link.Text.ToString().Trim();

        int isLayer = 0;
        try
        {
            isLayer = Convert.ToInt32(HsLayer.Value.ToString().Trim()) + 1;
        }
        catch
        {
        }

        string sDorder = Dorder.Text.ToString().Trim();
        string sEffective = Effective.SelectedValue.ToString().Trim();

        string sLevelCode = HLevelCode.Value.ToString().Trim();

        string sHEditType = HEditType.Value.ToString().Trim();

        if (sHEditType == "1")  //新建
        {
            int iback = MyUM.InsOutPageInfo(sOutPageID,sLabel, sIFLink, sLink, isLayer, "0", sDorder, sEffective, "");
            if (iback == 1)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('新建成功!');window.close();</script>");
                return;
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('新建失败!');</script>");
                return;
            }
        }
        else
        {  //修改
            int iback = MyUM.UPOutPageInfo(sHPageID,sHOldPageID , sOutPageID,sOldOutPageID, sLabel, sIFLink, sLink, isLayer, "0", sDorder, sEffective, "");
            if (iback == 1)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.close();</script>");
                return;
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');</script>");
                return;
            }
        }
    }
}
